<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"></html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
<script>
    window.onload = function() {
        document.getElementById('submit').addEventListener('click', function() {
            console.log("click")
            var urlNode = document.getElementById('url')
            var contentNode = document.getElementById('content')
            var timeNode = document.getElementById('time')
            // if(urlNode.value == '' || content.value == '' || time.value == '') {
            //     alert("请输入完整信息")
            // }
            console.log(urlNode.value)
            console.log(contentNode.value)
            console.log(timeNode.value)
            fetch('/comment', {
                method: 'POST',
                headers: {
                    'Content-Type': 'application/json',
                },
                // body:{
                //     url: 'https://blog.csdn.net/phoenix/web/v1/comment/submit',
                //     content: '456',
                //     time: '1000',
                // }
                body: JSON.stringify(
                    {
                        url: urlNode.value,
                        comment: contentNode.value,
                        time: timeNode.value,
                    }
                ),
            })
                .then(response => response)
                .then(data => {
                    console.log(data);
                })
                .catch(error => {
                    console.error(error);
                });
        });
    }
</script>
<h1>Hello World</h1>
<input type="text" id="url" name="url" placeholder="输入评论链接" style="width: 1000px;"> <br>
<input type="text" id="content" name="content" placeholder="输入评论内容" style="width: 400px;"> <br>
<input type="text" id="time" name="time" placeholder="输入延时时间(ms)" style="width: 400px;"> <br>
<button id="submit">提交</button>

</body>
</html>